/**
  ETFAna project, Anyang Normal University && IMP-CAS
  \class ETFTimer
  \brief To represent any type of timing detectors
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2022-04-26
  \date 2022-04-26 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2022-04-26   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021-2024 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#ifndef ETFTimer_h
#define ETFTimer_h

#include "ETFDetector.h"

class TClonesArray;
class ETFPlaHit;

class ETFTimer : public ETFDetector{
public:
  ETFTimer() : ETFDetector(){}
  ETFTimer(const char *name, double length);
  virtual ~ETFTimer();

  virtual void Initialize() override; ///< initialize the detector
  virtual void Register() override; ///< register hits to the main output tree
  /// \brief usually we let them all pass, but select them in the Filter() method
  /// speical for plastic scintillators, to get rid of L-R leading edge misalginment
  // virtual bool TrigBoundCheck(ETFHPTDCCh *ch) override{ return true; }
  virtual void PostAssign() override; ///< finish the processing of all the assigned data

  /// get the timing signal of Tstart
  virtual double GetTime() const = 0;
  virtual double time() const{ return GetTime(); }
  virtual int GetFiredStatus() const = 0;
  int fired() const{ return GetFiredStatus(); }
  TClonesArray *GetHits() const{ return fHits; }
  ETFPlaHit *GetHit(int i) const; ///< return fHits->At(i);
  virtual int nhits() const{ return GetNofHits(); }
  virtual int GetNofHits() const; ///< return fHits->GetEntriesFast();
  virtual void Print() override; ///< print the detector info

  // ClassDefOverride(ETFTimer, 0);

protected:
  TClonesArray *fHits; //! ///< an array of plastic hits, supposed to hold <= 1 hits

  /// stores the return value for GetTime()
  double fLength; //! ///< length of the plastic strip
};

#endif
